# Code Review and Analysis Commands

Commands for code review, diff inspection, project initialization, prompt generation, role definitions, and codebase indexing.

Back to: [Command Panel Guide](./09.0.Command%20Panel%20Guide.md)

---

## `/review`

Code review.

- **Function**: Open interactive code review panel to select content for review
- **Features**:
  - Automatically detect Git repository
  - Display staged changes with file count
  - Display unstaged changes with file count
  - Paginated loading of commit history (30 per page)
  - Multi-select: can select multiple review targets simultaneously
  - Support adding review notes
  - AI analyzes code quality, potential bugs, security issues
  - Provide optimization suggestions
- **Panel Operations**:
  - `Up/Down` - Move selection up/down
  - `Space` - Check/uncheck current item
  - `Enter` - Confirm selection and start review
  - `ESC` - Close panel
- **Selectable Review Targets**:
  - **Staged**: Staged changes
  - **Unstaged**: Unstaged changes
  - **Historical Commits**: Shows commit SHA, message, author, date
- **Examples**:
  - `/review` - Open review panel
  - Use Space key to select content to review in the panel, press Enter to confirm

## `/diff`

Review conversation file changes in Diff view.

- **Function**: Open the Diff Review panel to inspect files associated with earlier user messages in the conversation and show diffs in your IDE
- **Features**:
  - Lists conversation checkpoints based on session snapshots
  - Lets you preview single-file diffs first, then open all diffs for the selected message at once
  - Useful for reviewing code changes made by AI during the current session
- **Panel Operations**:
  - `↑/↓` - Select a message or file
  - `Tab` - Switch between the message list and the file list
  - `Enter` - Open all file diffs for the selected message
  - `ESC` - Close the panel
- **Prerequisite**: It is recommended to connect the VSCode/IDE plugin first, otherwise diffs cannot be shown inside the IDE
- **Example**: Type `/diff` to open the conversation diff review panel

## `/init`

Initialize project documentation.

- **Function**: AI analyzes current project and generates/updates AGENTS.md documentation
- **Features**:
  - Automatically explore project structure
  - Read configuration files and code
  - Generate project overview, tech stack, architecture description
- **Generated Content**: Project name, overview, tech stack, directory structure, features, usage instructions, etc.
- **Example**: Type `/init` in project root directory

## `/new-prompt`

Generate a refined prompt.

- **Function**: Open the Prompt Generator panel and turn your rough requirement into a prompt you can continue editing or send later
- **Features**:
  - Uses AI to transform natural-language requirements into a more structured prompt
  - Supports previewing, regenerating, or accepting the generated result
  - After accepting, the generated prompt is put back into the input box and is **not** sent automatically
- **Panel Operations**:
  - **Input step**: Enter your requirement and press `Enter` to start generating
  - **Preview step**: `↑/↓` scroll, `Y` accept, `R` regenerate, `N/ESC` cancel
- **Use Cases**: Helpful when you want to turn a vague idea into a clearer and more complete instruction
- **Example**: Type `/new-prompt` to open the prompt generator

## `/role`

Role definition file management.

- **Function**: Manage ROLE files (global and project scopes) to define the AI's role and behavior
- **Features**:
  - **Create**: `/role` - Open interactive panel to select creation location
    - Global location: `~/.snow/ROLE.md`
    - Project location: `./ROLE.md`
  - **Delete**: `/role -d` or `/role --delete` - Open deletion panel to select ROLE.md to delete
  - **List/Switch**: `/role -l` or `/role --list` - Open the ROLE management panel to list roles and switch the active one
- **Use Cases**: Customize AI behavior/output per project or set a global default
- **Panel Operations**:
  - **Creation Panel**: `G` - Select global, `P` - Select project, `ESC` - Cancel
  - **Deletion Panel**: `G` - Delete global, `P` - Delete project, `Y` - Confirm deletion, `N/ESC` - Cancel
  - **ROLE Management Panel (/role -l)**:
    - `Tab` - Switch Global / Project
    - `Up/Down` - Move selection
    - `Enter` - Set selected ROLE as active (marked as `[✓]` in the list)
    - `N` - Create a new inactive ROLE (file name like `ROLE-<id>.md`)
    - `D` - Delete selected inactive ROLE (requires confirmation: `Y` confirm, `N/ESC` cancel)
    - `ESC` - Close the panel
- **Active role persistence**:
  - Global: `~/.snow/role.json`
  - Project: `<project-root>/.snow/role.json`
  - Field: `activeRoleId` (missing or `active` reads `ROLE.md`; otherwise reads `ROLE-<activeRoleId>.md`)
- **Examples**:
  - `/role` - Open creation panel, select location and create ROLE.md
  - `/role -d` - Open deletion panel, select file to delete
  - `/role -l` - Open ROLE management panel

## `/reindex`

Rebuild codebase index.

- **Function**: Rescan and index project codebase
- **Prerequisite**: Need to enable codebase feature in configuration first
- **Parameters**:
  - No parameters: Incremental rebuild, skip unchanged files
  - `-force`: Force rebuild, delete existing database and rebuild from scratch
- **Use Cases**:
  - After codebase update to refresh index
  - Use `-force` when index is corrupted for complete rebuild
- **Examples**:
  - `/reindex` - Incremental index rebuild
  - `/reindex -force` - Force complete index rebuild

## `/codebase`

Manage codebase indexing for the current project.

- **Function**: Enable, disable, or check the current project's Codebase indexing status
- **Parameters**:
  - No parameters: `/codebase` - Toggle the current state directly
  - `on`: `/codebase on` - Enable codebase indexing
  - `off`: `/codebase off` - Disable codebase indexing
  - `status`: `/codebase status` - Show the current status
- **Prerequisite**: Before enabling it, configure embedding-related settings in `/home`
- **Behavior**:
  - Enabling saves the project setting and triggers indexing
  - Disabling stops indexing and file watching
- **Examples**:
  - `/codebase status` - Check status
  - `/codebase on` - Enable indexing
  - `/codebase off` - Disable indexing
